package com.thomas.framework.service.impl;

import com.thomas.framework.core.ServiceBase;
import com.thomas.framework.dao.ISysDictionaryDao;
import com.thomas.framework.entity.SysDictionary;
import com.thomas.framework.entity.SysDictionaryGroup;
import com.thomas.framework.service.ISysDictionaryService;
import com.thomas.framework.utils.CommonUtil;
import com.thomas.framework.utils.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by taohj on 2014/4/17.
 */

@Service
public class SysDictionaryServiceImpl extends ServiceBase<SysDictionary> implements ISysDictionaryService {


    private ISysDictionaryDao dao;



    @Autowired
    public void setDao(ISysDictionaryDao dao) {
        this.dao = dao;
    }




    @Override
    public  boolean create(SysDictionary dictionary){
        dictionary.setId(CommonUtil.getUUID());
        return  dao.insert(dictionary)>0;
    }

    @Override
    public  boolean remove(SysDictionary dictionary){
        return  dao.delete(dictionary)>0;
    }

    @Override
    public boolean modify(SysDictionary dictionary){
        return  dao.update(dictionary)>0;
    }

    @Override
    public  SysDictionary   getById(SysDictionary dictionary){

        return  dao.selectById(dictionary);
    }

    @Override
    public PageResult<SysDictionary> getByPage(PageResult<SysDictionary> pageResult){
        return  pageResult.setRows(dao.selectbyPage(pageResult));
    }

    @Override
    public SysDictionary get(SysDictionary dictionary) {
        return dao.select(dictionary);
    }


    public  List<SysDictionary> getList(SysDictionary dictionary){
        return  dao.selectList(dictionary);
    }


    public List<SysDictionary>  getListByDictionaryGroup(SysDictionaryGroup group){
        List<SysDictionary> list=null;

        SysDictionary dictionary=new SysDictionary();
        dictionary.setGroup(group);
        list=this.getList(dictionary);
        return  list;
    }

}
